//
//  AppDelegate.m
//  InstanceTypeTest
//
//  Created by wangrui on 14-1-10.
//  Copyright (c) 2014年 PPS. All rights reserved.
//

#import "AppDelegate.h"
#import "InstanceTypeTest.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    //测试零
    //[[InstanceTypeTest alloc] addSubview:nil]; //编译不能通过
    //[[[InstanceTypeTest alloc]init] addSubview:nil];  //编译不能通过 由于编译器实际上对init返回的id换成了instance，
    //所以发送不是示例对象的方法时会报错
    
    //测试一: createInstance返回类型为id时
    //[[InstanceTypeTest createInstance] addSubview:nil]; //编译能通过,这时返回的是真正的id. 对id可以放送任何存在的方法。运行时则会崩溃
    
    //测试二: createInstance返回类型为instance时4
    //[[InstanceTypeTest createInstance] addSubview:nil];//编译不能通过，addSubview不是类的示例方法
    
    [[InstanceTypeTest createInstance] test];

    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
